package com.why.simpleboot.core.core.aop.entity;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @program: why-simpleboot-framework
 * @description:
 * @author: @why
 * @create: 2021-05-26 16:59
 **/
public class MethodInvocation {


    /**
     * 封装需要代理的对象和方法  延迟执行
     */
    private Method method;
    private Object target;
    private Object[] args;

    public MethodInvocation(Method method, Object target, Object[] args) {
        this.method = method;
        this.target = target;
        this.args = args;
    }
    public Object invoke() {
        try {
            return method.invoke(target, args);
        } catch (IllegalAccessException | InvocationTargetException e) {
            e.printStackTrace();
        }
        return null;
    }
    public Method getMethod() {
        return method;
    }

    public Object getTarget() {
        return target;
    }

    public Object[] getArgs() {
        return args;
    }
}
